﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace PicACGTool.UserUtils.UserUtils.PicAcg
{
    internal class PicAcgLoginHelper
    {
        public static void TestLogin()
        {
            StartLogin(PicAcgStartValue.LoginAPI, "1968375523@qq.com", "124561215122");
        }

        /// <summary>
        /// 启动登录
        /// </summary>
        /// <param name="PostAPI"></param>
        /// <param name="UserName"></param>
        /// <param name="UserPass"></param>
        /// <returns></returns>
        public static bool StartLogin(string PostAPI, string UserName, string UserPass)
        {
            UserStartValue.PicAcgClient.Headers = InitHeader();
            string Shtml = UserStartValue.PicAcgClient.SendPost(PostAPI, "{\"email\":\"" + UserName + "\",\"password\":\"" + UserPass + "\"}");
            Console.WriteLine(Shtml);
            return false;
        }

        private static WebHeaderCollection InitHeader()
        {
            WebHeaderCollection webHeader = new WebHeaderCollection();
            webHeader.Add("Host: api.wakamoment.ga");
            webHeader.Add("User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0");
            webHeader.Add("Accept: application/vnd.picacomic.com.v1+json");
            webHeader.Add("Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            webHeader.Add("Accept-Encoding: gzip, deflate, br");
            webHeader.Add("Referer: https://picaadmin.picacomic.com/");
            webHeader.Add("api-key: 61E932C772B58BB87ACFEF6FCACDF");
            return webHeader;
        }
    }
}